/** @type {import('next').NextConfig} */

const path = require('path');
const env = require('./env');

// basePath
function getBasePath() {
  if (process.env.NEXT_PUBLIC_ENV === "test") {
    return '/xz-h5pc'
  }
  return ""
}

module.exports = {
  distDir: '_next',
  reactStrictMode: true,
  compress: true,
  trailingSlash: true,
  basePath: getBasePath(),
  // 引入文件方式， 改为“@/*”，摒弃“../../”的方式
  // 需要配置jsconfig.json文件
  webpack: (config) => {
    config.resolve.alias["@"] = path.resolve(__dirname);
    return config;
  },
  env: {
    baseUrl: env[process.env.NEXT_PUBLIC_ENV].BASE_URL,
    basePath: getBasePath()
  },
  images: {
    domains: ['tx.enn.cn'] 
  }
}
